<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Đặng Khánh Trung
 * Date: 11/2/12
 * Time: 11:33 AM
 * To change this template use File | Settings | File Templates.
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.multiselect');
JHtml::_('behavior.mootools');

$document = JFactory::getDocument();
$document->addStyleSheet(JURI::root() . 'components/com_vast/assets/autocomplete/meio.aucomplete.css');
$document->addStyleSheet(JURI::root() . 'components/com_vast/assets/css/jquery.autocomplete.css');
$document->addStyleSheet(JURI::root() . 'components/com_vast/assets/css/thickbox.css');

$document->addScript(JURI::root() . 'components/com_vast/assets/autocomplete/Builder.js');

$document = JFactory::getDocument();
$autocompleteDir = JURI::root() . '/components/com_vast/assets/autocomplete/';

$tongiaoJSON = $this->get('tongiaoJSON');
$dantocJSON = $this->get('dantocJSON');

$script=<<<AUTOCOMPLETE
    Builder.build('{$autocompleteDir}', {
        Source: [
            'BGIFrame',
            'Meio.Autocomplete'
        ]
    });
    window.addEvent('domready', function() {
        var data = [
            {$tongiaoJSON}
        ];

        var instance = new Meio.Autocomplete($('jform_tongiao'), data, {
            selectOnTab: false,
            onNoItemToList: function(elements){
                elements.field.node.highlight('#ff0000');
            },
            filter: {
                type: 'contains',
                path: 'text'
            }
        });        
    });
    
    window.addEvent('domready', function() {
        var data = [
            {$dantocJSON}
        ];

        var instance = new Meio.Autocomplete($('jform_dantoc'), data, {
            selectOnTab: false,
            onNoItemToList: function(elements){
                elements.field.node.highlight('#ff0000');
            },
            filter: {
                type: 'contains',
                path: 'text'
            }
        });        
    });    
    window.addEvent('domready', function() {
        document.formvalidator.setHandler('hoten',
            function (value) {
                regex=/^(\w*)(\s*)(.*){1,128}$/;
                if (!regex.test(value))
                    alert('Giá trị họ tên không hợp lệ phải có tối thiểu 1 chữ cái và tối đa 128 chữ cái');
                return regex.test(value);
            });
    });
AUTOCOMPLETE;

$document->addScriptDeclaration($script);

$item = $this->get('item');
if (!JFactory::getUser()->authorise('vast.hosocanbo.create', 'com_vast') && !(JFactory::getUser()->authorise('vast.hosocanbo.manage', 'com_vast')))
{
    JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_vast&view=vast'));                        
}
?>

<div id="crumbs">
    <div style="color: #222222;font-weight: normal;margin: 0;padding: 0">
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=vast') ?>">Trang chủ</a> »
        <span>Cơ cấu tổ chức</span> »
        <span>Thêm mới hồ sơ cán bộ</span>
    </div>
</div>

<div id="main" class="home">
    <h3 class="title green">Thông tin cơ bản của một hồ sơ cán bộ</h3>
    
    <div class="form">
        <form class="commentform form-validate" action="<?php echo JRoute::_('index.php?option=com_vast&view=hosocanbo&layout=default'); ?>" method="post" id="hosocanbo" name="adminForm">
            
            <div class="row">
                <?php echo $this->form->getLabel('id'); ?>
                <?php echo $this->form->getInput('id'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('nguoidung_id'); ?>
                <?php echo $this->form->getInput('nguoidung_id'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('hoten'); ?>
                <?php echo $this->form->getInput('hoten'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('gioitinh'); ?>
                <?php echo $this->form->getInput('gioitinh'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('ngaysinh'); ?>
                <?php echo $this->form->getInput('ngaysinh'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('taikhoandientu'); ?>
                <?php echo $this->form->getInput('taikhoandientu'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('sohieu'); ?>
                <?php echo $this->form->getInput('sohieu'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('chungminhnhandan'); ?>
                <?php echo $this->form->getInput('chungminhnhandan'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('ngaycap'); ?>
                <?php echo $this->form->getInput('ngaycap'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('noicap'); ?>
                <?php echo $this->form->getInput('noicap'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('masothue'); ?>
                <?php echo $this->form->getInput('masothue'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('noisinh'); ?>
                <?php echo $this->form->getInput('noisinh'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('nguyenquan'); ?>
                <?php echo $this->form->getInput('nguyenquan'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('diachihientai'); ?>
                <?php echo $this->form->getInput('diachihientai'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('dienthoai'); ?>
                <?php echo $this->form->getInput('dienthoai'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('didong'); ?>
                <?php echo $this->form->getInput('didong'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('thudientu'); ?>
                <?php echo $this->form->getInput('thudientu'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('dantoc'); ?>
                <?php echo $this->form->getInput('dantoc'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('tongiao'); ?>
                <?php echo $this->form->getInput('tongiao'); ?>
            </div>
            
            <div class="row">
                <input type="hidden" name="option" value="com_vast" />
                <input type="hidden" name="task" value="hosocanbo.create" />
            </div>
            
            <div class="row buttons">
                <button type="submit" class="button validate" id="submit"><?php echo JText::_('Thêm hồ sơ cán bộ'); ?></button>
                <?php echo JHtml::_('form.token'); ?>
            </div>
        </form>
    </div>
</div>